import request from '@/utils/request'

/**
 * 所有分类
 * @returns Promise
 */
export const findAllCategoryAPI = () => request('/home/category/head')

/**
 * 一级分类
 * @param {String} id 必传
 * @returns Promise
 */
export const findFirstCategoryAPI = id => request('/category', { id })

/**
 * 获取二级分类筛选条件数据
 * @param {String} id - 二级分类ID
 */
export const findSubCategoryFilterAPI = id =>
  request('/category/sub/filter', { id })

/**
 * 获取二级分类筛选条件数据
 * @param {String} sortField - 排序字段，取值范围：[publishTime,orderNum,price,evaluateNum]
 * @param {String} sortMethod - 排序规则，asc为正序，desc为倒序，默认为desc
 * @param {Boolean} inventory - 是否有库存
 * @param {Boolean} onlyDiscount - 只显示特惠
 */
export const findGoodsAPI = data =>
  request('/category/goods/temporary', data, 'post')
